//
//  HZ_Listening_CollectionViewCell.m
//  HZ_Beautiful_Music
//
//  Created by dllo on 16/4/1.
//  Copyright © 2016年 ui. All rights reserved.
//

#import "HZ_Listening_CollectionViewCell.h"
#import "UIImageView+WebCache.h"
@interface HZ_Listening_CollectionViewCell ()



@property (nonatomic, strong) UILabel *Musicnamelabel;
@property (nonatomic, strong) UILabel *namellabel;
@property (nonatomic, strong) UILabel *lovelabel;
@property (nonatomic, strong) UILabel *qualitylabel;
@property (nonatomic, strong) UIImageView *Pictureimage;
@property (nonatomic, strong) UIImageView *loveimage;
@property (nonatomic, strong) UIImageView *playimage;

@end
@implementation HZ_Listening_CollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    
    self = [super initWithFrame:frame];
    
    
    if (self) {
       
        
//       self.backgroundColor = [UIColor clearColor];
        
        self.sortlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width / 10, self.bounds.size.height)];
        
        self.sortlabel.backgroundColor = [UIColor clearColor];
        _sortlabel.textAlignment = 1;
        [self.contentView addSubview:self.sortlabel];
        
        self.Pictureimage = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width / 10, self.bounds.size.height / 6, 4 * self.bounds.size.height / 6, 4 * self.bounds.size.height / 6)];
        
        self.Pictureimage.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:self.Pictureimage];
        
        self.Musicnamelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width / 10 + 4 * self.bounds.size.height / 6 + 5, self.Pictureimage.frame.origin.y,  10, self.Pictureimage.bounds.size.height / 2)];
        
//        [self.Musicnamelabel sizeToFit];
        self.Musicnamelabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.Musicnamelabel];
        
        
        self.namellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.Musicnamelabel.frame.origin.x, self.Pictureimage.frame.origin.y + self.Pictureimage.bounds.size.height / 2, 10, self.Pictureimage.bounds.size.height / 2)];
        
        [self.namellabel sizeToFit];
        self.namellabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.namellabel];
        
        
        self.loveimage = [[UIImageView alloc] init];
        
        self.loveimage.image = [UIImage imageNamed:@"collection"];
        self.loveimage.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.loveimage];
        
        self.lovelabel = [[UILabel alloc] init];
        
        self.lovelabel.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:self.lovelabel];
        
        
        self.playimage = [[UIImageView alloc] initWithFrame:CGRectMake(7 * self.bounds.size.width / 8, self.bounds.size.height / 2 - self.bounds.size.width / 16,  self.bounds.size.width / 8,  self.bounds.size.width / 8)];
        
        self.playimage.image = [UIImage imageNamed:@"iconfont-bofang-3"];
        self.playimage.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.playimage];
    }
    
    
    return self;
    
    
    
    
}

-(void)setModel:(HZ_songs_Model *)model{

    _model = model;
    [self.Pictureimage sd_setImageWithURL:[NSURL URLWithString:_model.picUrl]];
    self.Musicnamelabel.text = _model.name;
    [_Musicnamelabel sizeToFit];
    self.namellabel.text = _model.singerName;
    [_namellabel sizeToFit];
    
    _loveimage.frame = CGRectMake(self.namellabel.frame.origin.x + self.namellabel.bounds.size.width + 5, self.namellabel.frame.origin.y, 25, 25);
    _lovelabel.frame = CGRectMake(self.loveimage.frame.origin.x + self.loveimage.bounds.size.width + 5, self.namellabel.frame.origin.y , self.bounds.size.width / 8, self.bounds.size.width / 10);
    if (_model.favorites > 10000) {
        
        NSString *string = [NSString stringWithFormat:@"%0.1f万", _model.favorites / 1000 * 0.1];
        self.lovelabel.text = string;
        
    } else {

    NSString *str = [NSString stringWithFormat:@"%ld", _model.favorites];
 
    self.lovelabel.text = str;
    }
    [_lovelabel sizeToFit];

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
